def bubbleSort(numbers):
    swap_count = 0
    n = len(numbers)
    
    for i in range(n):
        for j in range(0, n - i - 1):
            if numbers[j] > numbers[j + 1]:
                # 交换相邻元素
                numbers[j], numbers[j + 1] = numbers[j + 1], numbers[j]
                swap_count += 1
                
    return swap_count


# === DO NOT modify the code below ===
def main():
    a = [ eval(x) for x in input().split() ]
    print(bubbleSort(a))
    print(" ".join(map(str,a)))
    
if __name__ == '__main__':
    main()
# === DO NOT modify the code above ===